﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using RuleCode.Table;

namespace map.member
{
    public partial class default1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                cbuser u = cbuser.getcuruser();
                cbshop s = cbshop.findorcreate(u.cbuserid.ToString());
                cbshoppage sp = cbshoppage.Find(" cbshoppageid = '"
                + cbshop.transhoppageid(this.Request.Params["cbshoppageid"].ToString())
                + "' and cbuserid = '" + u.cbuserid.ToString()+"'"
                );
                Literal_0.Text = cbshop.dealurl (this.Request,sp.cbcodeb0.ToString());
                Literal_1.Text = cbshop.dealurl (this.Request,sp.cbcodeb1.ToString());
                Literal_2.Text = cbshop.dealurl (this.Request,sp.cbcodeb2.ToString());
                Literal_3.Text = cbshop.dealurl (this.Request,sp.cbcodeb3.ToString());
                Literal_4.Text = cbshop.dealurl (this.Request,sp.cbcodeb4.ToString());
                cbshopcss sc = cbshopcss.findorcreate(u.cbuserid.ToString());
                string css = sc.getstylestring();
                Literalcss.Text = css;
                string backpicpath = sp.backpicpath.ToString();
                string backcolour = sp.backcolour.ToString();
                if (backpicpath == "")
                {
                    backpicpath = sc.alltoppic.ToString();
                }
                if (backcolour == "")
                {
                    backcolour = sc.allbackcolor.ToString();
                }
                string back = "<script type =\"text/javascript\" >setbackpic('url(.."
                    + backpicpath + ")');setbackcolor('" + backcolour + "');</script>";
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(),
                    "zback", back, false);

                if (s.cbpath0.ToString() != "")
                {
                    HtmlLink icoLink = new HtmlLink();
                    icoLink.Href = ResolveUrl(s.cbpath0.ToString());
                    icoLink.Attributes.Add("rel", "shortcut icon");
                    Page.Header.Controls.Add(icoLink);
                }
                addtitle();
                if (this.Request.Params["cbshoppageid"].ToString() == "0")
                {
                    this.Page.Title +="-"+ s.cbshoptitle.ToString();
                }
            }
        }
        private void addheadinfo()
        {
            ////Page title
            //if (Page.Title.Length > 3)
            //{
            //    if (Page.Title.Substring(0, 3) != "销售宝")
            //    {
            //        Page.Title = "销售宝-" + Page.Title;
            //    }
            //}
            //else
            //{
            //    Page.Title = "销售宝-" + Page.Title;
            //}



            //Encode/Content type

            HtmlMeta encode = new HtmlMeta();

            encode.HttpEquiv = "Content-Type";

            encode.Content = "textml; charset=utf-8";

            Page.Header.Controls.Add(encode);



            //Language

            HtmlMeta lang = new HtmlMeta();

            lang.HttpEquiv = "Content-Language";

            lang.Content = "zh-cn";

            Page.Header.Controls.Add(lang);



            //Description

            //HtmlMeta desc = new HtmlMeta();

            //desc.Name = area.cbname.ToString();

            //desc.Content = area.jcdesc.ToString();

            //Page.Header.Controls.Add(desc);



            //Google管理员工具

            //HtmlMeta keywords = new HtmlMeta();

            //keywords.Name = area.googlename.ToString();

            //keywords.Content = area.googlecontent.ToString();

            //Page.Header.Controls.Add(keywords);

            //nk/ico if (area.iconpath.ToString() != "")
            //{
            //    HtmlLink icoLink = new HtmlLink();
            //    icoLink.Href = ResolveUrl(area.iconpath.ToString());
            //    icoLink.Attributes.Add("rel", "shortcut icon");
            //    Page.Header.Controls.Add(icoLink);
            //}



        }
        private void addtitle()
        {
            if (this.Request.Params["cbshoppageid"] == null)
            {
                return;
            }
            this.Title =
                    cbshop.transhoppageid(this.Request.Params["cbshoppageid"].ToString());
            if (this.Request.Params["cbshoppageid"].ToString() == "1")
            {
                string cataid = "";
                if (this.Request.Params["itemcataid"] != null)
                {
                    cataid = this.Request.Params["itemcataid"].ToString();
                    taobaoItemCat ic = taobaoItemCat.Find("taobaocid ='" + cataid + "'");
                    this.Title = ic.taobaoname.ToString();
                }
            }
            if (this.Request.Params["cbshoppageid"].ToString() == "2")
            {
                string itemid = "";
                if (this.Request.Params["itemid"] != null)
                {
                    itemid = this.Request.Params["itemid"].ToString();
                    taobaouseritems ui = taobaouseritems.Find(" recid =  " + itemid);
                    this.Title = ui.taobaotitle.ToString();
                }
            }
            if (this.Request.Params["cbshoppageid"].ToString() == "5")
            {
                string cataid = "0";
                if (this.Request.Params["value"] != null)
                {
                    cataid = this.Request.Params["value"].ToString();
                }
                cbcata c = cbcata.Find(" cbcataid = '" + cataid + "' ");
                this.Title = c.cbname.ToString();
            }
            if (this.Request.Params["cbshoppageid"].ToString() == "6")
            {
                string id = "0";
                if (this.Request.Params["value"] != null)
                {
                    id = this.Request.Params["value"].ToString();
                }
                cblist l = cblist.Find("cblistid='" + id + "'");
                this.Title = l.cbtitle.ToString();
            }
        }
    }
}
